/*
 *  EventLib
 *  qEvent.cpp
 *
 *	Copyright (c) 2011, AVS
 *	All rights reserved.
 *
 *	Redistribution and use in source and binary forms, with or without
 *	modification, are permitted provided that the following conditions are met:
 *	1.	Redistributions of source code must retain the above copyright
 *		notice, this list of conditions and the following disclaimer.
 *	2.	Redistributions in binary form must reproduce the above copyright
 *		notice, this list of conditions and the following disclaimer in the
 *		documentation and/or other materials provided with the distribution.
 *	3.	All advertising materials mentioning features or use of this software
 *		must display the following acknowledgement:
 *		This product includes software developed by the AVS.
 *	4.	Neither the name of the AVS nor the
 *		names of its contributors may be used to endorse or promote products
 *		derived from this software without specific prior written permission.
 *
 *	THIS SOFTWARE IS PROVIDED BY AVS ''AS IS'' AND ANY
 *	EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 *	WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 *	DISCLAIMED. IN NO EVENT SHALL AVS BE LIABLE FOR ANY
 *	DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 *	(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 *	LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 *	ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 *	(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 *	SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include "qEvent.h"

EventState *gp_EventState = NULL;

qEvent::qEvent()
:	type(DEFAULT_EVENT)
{
}

qEvent::qEvent(std::string _name)
:	name(_name)
{
}

qEvent::qEvent(int _key, KEY_TYPE _state, EVENT_TYPE _type)
:	type(_type)
{
	this->data.key.key = _key;
	this->data.key.state = _state;
}

qEvent::qEvent(int _x, int _y, EVENT_TYPE _type)
:	type(_type)
{
	this->data.mouse.x = _x;
	this->data.mouse.y = _y;
}

qEvent::qEvent(void *data, EVENT_TYPE _type)
:	type(_type)
{
	this->data.game.data = data;
}

qEvent::~qEvent()
{
}

int qEvent::get_key_code()
{
	return this->data.key.key;
}

KEY_TYPE qEvent::get_key_state()
{
	return this->data.key.state;
}

void qEvent::REGISTER_SCRIPTABLES(qScriptEngine *engine)
{
	REGISTER_CLASS(engine, "qEvent", qEvent);
	
	REGISTER_METHOD(engine, "qEvent", qEvent, "string &getName()", getName);
	REGISTER_METHOD(engine, "qEvent", qEvent, "int getType()", getType);
	REGISTER_METHOD(engine, "qEvent", qEvent, "int get_key_code()", get_key_code);
	REGISTER_METHOD(engine, "qEvent", qEvent, "int get_key_state()", get_key_state);
	REGISTER_METHOD(engine, "qEvent", qEvent, "int get_mouse_x()", get_mouse_x);
	REGISTER_METHOD(engine, "qEvent", qEvent, "int get_mouse_y()", get_mouse_y);
	
	REGISTER_METHOD(engine, "qEvent", qEvent, "void &get_game_data()", get_game_data);
	//REGISTER_METHOD(engine, "err", err, "string &get_err()", get_err);
	
	//REGISTER_GLOBAL_PROPERTY(engine, "int KEY_a", KEY::KEY_a);
}